package com.aube.model;

import com.huyn.baseframework.model.VideoPlayModel;
import com.huyn.baseframework.model.VideoWithDefinitionModel;
import com.huyn.baseframework.utils.StringUtils;

import java.io.Serializable;
import java.util.List;

/**
 * Created by huyaonan on 15/11/7.
 */
public class VideoItem implements Serializable {
    public String videoid;//主键
    public String videono="";
    public String videoTitle="";
    public String videoDesc="";
    public int duration;

    public String videoType="";
    public String soundSwitch="";

    public String cameraType="";
    public String updownAngle="";
    public String leftRightAngle="";

    public VideoWithDefinitionModel videoPlay;

    /**
     * add on Jan 11th 2017
     * 分镜头出现的位置
     */
    public String aubeVideoid;
    public String displayStyle;
    public List<VideoItemCoordinate> displayRect;

    public boolean isPipMode() {
        return "pip".equalsIgnoreCase(displayStyle);
    }

    public float getX() {
        if(displayRect == null || displayRect.size() == 0)
            return 0;
        return displayRect.get(0).pointxPercent;
    }

    public float getY() {
        if(displayRect == null || displayRect.size() == 0)
            return 0;
        return displayRect.get(0).pointyPercent;
    }

    //vr
    public boolean isVr = false;
    public boolean isVr() {
        return "vr".equalsIgnoreCase(cameraType);
    }

    public int delayTime;
    public int index;

    public VideoItem(String title) {
        this.videoTitle =  title;
    }

    public boolean enableSound() {
        return "Y".equalsIgnoreCase(soundSwitch);
    }

    public void updateDelay(int delay) {
        this.delayTime -= delay;
    }

    public VideoPlayModel getVideo() {
        VideoPlayModel model = new VideoPlayModel();
        model.videoId = getVideoId();
        model.videoNo = videono;
        model.videoModel = videoPlay;
        return model;
    }

    public String getVideoId() {
        return StringUtils.isNotBlank(aubeVideoid) ? aubeVideoid : videoid;
    }

}
